import request from '@/utils/request'

// 获取筛选列表接口
export const getJobByService = (Data)=>{
    var params = new URLSearchParams();
    for (let key in Data) {
        params.append(key, Data[key])
    }
    //添加完之后，params的格式自动给转为：username=xxx&password=xxx&repassword=xxx
    return request.post('/job/getJobBys', params);
}


// 获取所有工作列表接口
export const getJobListService = ()=>{
    //添加完之后，params的格式自动给转为：username=xxx&password=xxx&repassword=xxx
    return request.post('/job/getJobList');
}

export const JobListService = (data)=>{
    var params = new URLSearchParams();
    for (let key in data) {
        params.append(key, data[key])
    }
    return request.post('/job/page', params)
}

// 岗位细节
export const getJobDetailsService = (jobId)=>{
    return request.post(`/job/jobDetails?jobId=${jobId}`)
}

//公司细节
export const getCompanyDetailsService = (companyId)=>{
    return request.post(`/company/CompanyDetails?companyId=${companyId}`)
}

//公司发布的岗位信息
export const getCompanyJobListService = (companyId)=>{
    return request.post(`/job/getCompanyJob?companyId=${companyId}`)
}

//投递简历
export const PostJOBService = (userId, jobId, companyId)=> {
    return request.post(`/job/postJob?userId=${userId}&jobId=${jobId}&companyId=${companyId}`)
}

//收藏职位
export const FavorJOBService = (userId, jobId, companyId, sss)=> {
    return request.post(`/job/favorJob?userId=${userId}&jobId=${jobId}&companyId=${companyId}&sss=${sss}`)
}


//查看简历投递状态
export const CheckJOBService = (userId, jobId, companyId)=> {
    return request.post(`/job/checkPostJob?userId=${userId}&jobId=${jobId}&companyId=${companyId}`)
}

// 工作简历
export const postJobResumeService = (jobResume)=>{
    const requestBody = {
        jobResume:jobResume,
    };
    return request.patch('/job/jobResume',requestBody);
}

//分页查找所有企业信息
export const getAllCompanyService = (data)=>{
    var params = new URLSearchParams();
    for (let key in data) {
        params.append(key, data[key])
    }
    return request.post('/company/page', params)
}

//分页查看职位信息
export const getAllJobsService = (data)=>{
    var params = new URLSearchParams();
    for (let key in data) {
        params.append(key, data[key])
    }
    return request.post('/job/getJobBys', params)
}

//逻辑删除职位
export const UpdateJobStatusService = (jobId, status)=>{
    return request.post(`/job/deleteJob?jobId=${jobId}&status=${status}`)
}

//获取企业发布的岗位
export const getPublicJobs = (companyId)=>{
    return request.post(`/job/getCompanyJob?companyId=${companyId}`)
}

//获取职位收到的简历数据
export const getResumeListService = (jobId, companyId)=>{
    return request.post(`/job/getJobResumes?jobId=${jobId}&companyId=${companyId}`)
}

//获取推荐职位的数据
export const GetRecommendedJobListService = ()=>{
    return request.post(`/job/JobRecommend`)
}

//获取推荐简历的数据
export const GetRecommendedResumeListService = (jobId)=>{
    return request.post(`/job/resumeRecommend?jobId=${jobId}`)
}

//获取投递状态
export const getPersonalMessage = (userId, jobId, companyId)=>{
    return request.post(`/job/checkPostJob?userId=${userId}&jobId=${jobId}&companyId=${companyId}`)
}

//获取公司邀请状态
export const getCompanyMessage = (userId, companyId, postId)=>{
    return request.post(`/job/checkCompanyInvite?userId=${userId}&companyId=${companyId}&postId=${postId}`)
}

//获取岗位以及公司的数量
export const getCountService = ()=>{
    return request.get('/job/getCount')
}

//获取热门岗位
export const getPopularJobService = ()=> {
    return request.get('/job/getHotJobList')
}

//获取热门企业及其岗位
export const getPopularCompanyAndJobService = ()=> {
    return request.get('/company/getHotCompanyList')
}

//获取热门的职位
export const getTopJobService = (data)=> {
    var params = new URLSearchParams();
    for (let key in data) {
        params.append(key, data[key])
    }
    return request.post('/job/getTopJob', params)
}

//筛选工作
export const JobSearchService = (data)=> {
    var params = new URLSearchParams();
    for (let key in data) {
        params.append(key, data[key])
    }
    return request.post('/job/searchJob', params)
}